package com.sky.mapper;


import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    //通过DTO查询用户的指定菜品需求
    ShoppingCart getById(ShoppingCartDTO shoppingCartDTO, Long currentId);

    //更新购物车
    @Update("update sky_take_out.shopping_cart set number=#{number} where id=#{id}")
    void updateShoppingCart(ShoppingCart shoppingCart);

    //添加购物车
    void insertShoppingCart(ShoppingCart shoppingCart);

    //查看购物车
    @Select("select * from sky_take_out.shopping_cart where user_id=#{currentId}")
    List<ShoppingCart> getListByUserId(Long currentId);

    //删除购物车菜品信息
    void deleteShoppingCart(ShoppingCart shoppingCart);

    //清空购物车
    @Delete("delete from sky_take_out.shopping_cart where user_id=#{currentId}")
    void cleanShoppingCart(Long currentId);

    //动态条件查询
    List<ShoppingCart> list(ShoppingCart shoppingCart);

    //根据用户id删除购物车数据
    @Delete("delete from shopping_cart where user_id = #{userId}")
    void deleteByUserId(Long userId);

    //批量插入购物车数据
    void insertBatch(List<ShoppingCart> shoppingCartList);
}
